#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    label = new QLabel(this);
    QRect ret(200, 300, 300, 200);
    label->setGeometry(ret);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime old = ui->dateTimeEdit->dateTime();
    QDateTime now = ui->dateTimeEdit_2->dateTime();
    //int days = old.daysTo(now);
    int seconds = old.secsTo(now);
    int n = (seconds / 3600) % 24;
    int day = (seconds / 3600) / 24;
    label->setText("爱你已经持续了 " + QString::number(day) + " 天零 "+ QString::number(n) + " 小时");
}
